<template>
  <div class="followup-box inner-content">
    <div class="inner inner-content-box">
      <div class="searchBox">
        <el-form
          :inline="true"
          :model="searchForm"
          size="small"
          style="width: 100%"
        >
          <el-form-item label="考试名称">
            <el-input
              v-model="searchForm.recordsName"
              placeholder="考试名称"
              clearable
              style="width: 120px"
            ></el-input>
          </el-form-item>
          <el-form-item>
            <el-button
              type="primary"
              @click="getList"
              size="small"
              icon="el-icon-search"
              >搜索</el-button
            >
            <el-button @click="searchReset" size="small" icon="el-icon-delete"
              >清空</el-button
            >
          </el-form-item>
          <br />
          <el-form-item>
            <el-tooltip placement="bottom" effect="light" v-if="isAuth('examTest:list:addB')">
              <div slot="content" class="tipCon">
                <div class="title">B类：排考考试</div>
                <div class="line"><span class="order">1、</span><span class="orderCon">考试前按照考生名单排考；</span></div>
                <div class="line"><span class="order">2、</span><span class="orderCon">发布准考证，考生自行打印准考证，按照准考证报到进行考试；</span></div>
                <!-- <div class="line"><span class="order">3、</span><span class="orderCon">也可自定义分组考试或快速开考。</span></div> -->
              </div>
              <el-button
                v-if="isAuth('examTest:list:addB')"
                size="small"
                type="primary"
                @click="addExamTest"
              >
                <span class="icon iconfont icon-kaoshi"></span>
                新增B类考试
              </el-button>
            </el-tooltip>
            <el-tooltip placement="bottom" effect="light" v-if="isAuth('examTest:list:addA')">
              <div slot="content" class="tipCon">
                <div class="title">A类：抽签考试</div>
                <div class="line"><span class="order">1、</span><span class="orderCon">考试前按照每场考生人数，以数字序号进行排考；</span></div>
                <div class="line"><span class="order">2、</span><span class="orderCon">每场考生在考试开始前集中报到，抽签决定考试轮次和分组，按抽中的序号进行考试。</span></div>
              </div>
              <el-button
                v-if="isAuth('examTest:list:addA')"
                size="small"
                type="success"
                @click="addExamTestCountry"
              >
                <span class="icon iconfont icon-kaoshi"></span>
                新增A类考试
              </el-button>
            </el-tooltip>
            <!-- <el-button
              v-if="isAuth('examinee:list:delete')"
              size="small"
              type="danger"
              @click="delHandle('branch')"
              :disabled="dataSelect.length == 0"
            >
              <span class="el-icon-delete"></span>
              删除
            </el-button> -->
          </el-form-item>
        </el-form>
      </div>
      <div class="detailsBox">
        <ag-grid-vue
          class="ag-theme-alpine ag-theme-quartz"
          :gridOptions="gridOptions"
          :localeText="localeText"
          :rowHeight="38"
          :headerHeight="42"
          @grid-ready="onGridReady"
          @selection-changed="getSelectedRows"
          @sort-changed="onSortChangedAggrid"
          @filter-changed="onFilterChangedAggrid"
          :isRowSelectable="isRowSelectable"
          :columnDefs="columnDefs"
          :defaultColDef="defaultColDef"
          :rowData="rowData"
          rowSelection="multiple"
          :rowMultiSelectWithClick="true"
          :enableRangeSelection="true"
        >
        </ag-grid-vue>
      </div>
      <div class="pageBox">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="page.currentPage"
          :page-sizes="page.pageSizes"
          :page-size="page.pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="page.total"
        >
        </el-pagination>
      </div>
    </div>
    <examTextAddEdit ref='examTextAddEdit' :examTestVisible="examTestVisible" :addOrEdit='addOrEdit' @closeHandle="closeHandle" :passwordCheck="passwordCheck"></examTextAddEdit>
    <addEditExamCountry ref='addEditExamCountry' :examTestVisible="examTestCountryVisible" :addOrEdit='addOrEditCountry' @closeHandle="closeHandleCountry" :passwordCheck="passwordCheck"></addEditExamCountry>
    <el-dialog
      title="校验密码"
      :visible.sync="passwordVisible"
      width="500px"
      :before-close="handleClosePwd">
      <div>
        <el-form :model="passwordForm" :rules="passwordFormRules" ref="passwordForm" label-width="160px" style="padding-right: 30px;padding-top: 10px;" label-position="right">
          <el-form-item label="请输入密码：" prop="password">
            <el-input type="password" style="width: 240px" v-model="passwordForm.password" autocomplete="off" placeholder="请输入密码"></el-input>
          </el-form-item>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="handleClosePwd">取 消</el-button>
        <el-button type="primary" @click="submitPassword('passwordForm')">确 定</el-button>
      </span>
    </el-dialog>
    <examDetail ref="examDetail" :password="passwordForm.password"></examDetail>
  </div>
</template>
<script>
// import Vue from 'vue'
import listBtn from '@/views/modules/examTest/listBtn.vue'
import ifUseView from '@/views/modules/examTest/ifUseView.vue'
import examDataSolt from '@/views/modules/examTest/examDataSolt.vue'
import examTextAddEdit from '@/views/modules/examTest/addEditExam/index.vue'
import addEditExamCountry from '@/views/modules/examTest/addEditExamCountry/index.vue'
import examDetail from '@/views/modules/examTest/examDetail.vue'
import listJson from '@/views/modules/examTest/list.json'
import { fetchList, recordsDelete, checkStudent, getQrCode } from '@/api/examTest.js'
import { recordsxishuSaveB } from '@/api/examinationScore.js'
import { authCheck, initializePwd } from '@/api/index'
export default {
  beforeMount () {
    this.gridOptions = {
      // 通过这个属性建立了上下文引用
      context: { componentParent: this }
      // 说人话就是可以在自己声明的组件里调用到父组件的方法和属性了
    }
  },
  components: {
    listBtn,
    ifUseView,
    examDataSolt,
    examTextAddEdit,
    addEditExamCountry,
    examDetail
  },
  data () {
    return {
      dataSelect: [],
      gridOptions: null,
      localeText: this.$AG_GRID_LOCALE_ZZZ,
      col: [],
      page: {
        pageSizes: [100, 2000, 5000],
        currentPage: 1,
        total: 0,
        pageSize: 100
      },
      searchForm: {
        recordsName: ''
      },
      defaultColDef: {
        editable: false,
        sortable: true,
        resizable: true,
        filter: true,
        cellDataType: false
      },
      isRowSelectable: null,
      rowIndexArr: [
        {
          field: 'rowIndex',
          headerName: '序号',
          width: 80,
          checkboxSelection: false,
          headerCheckboxSelection: false,
          sortable: false,
          pinned: 'left',
          valueGetter: (params) => {
            // 返回当前行的序号
            return params.node.rowIndex + 1
          }
        },
        {
          field: 'handle',
          headerName: '操作',
          width: 260,
          pinned: 'right',
          cellRenderer: 'listBtn'
        }
      ],
      columnDefs: [ ],
      gridApi: null,
      rowData: [],
      examTestVisible: false,
      addOrEdit: 'add',

      examTestCountryVisible: false,
      addOrEditCountry: 'add',
      msg: null,

      // 密码 start
      passwordVisible: false,
      passwordForm: {
        password: ''
      },
      passwordFormRules: {
        password: [{ required: true, message: '密码不能为空', trigger: 'change' }]
      },
      passwordCheck: '',
      examinationIdDialog: '',
      // 下一步的操作
      byPwdFlag: '',
      userInfo: this.$store.state.user,
      // 密码 end
      examDetailShow: false
    }
  },
  watch: {
    $route: {
      handler (newValue, oldValue) {
        if (oldValue.name === 'examTest-list') {
          this.examTestVisible = false
          this.examTestCountryVisible = false
          this.$refs.examDetail.closeHandle()
        }
      },
      deep: true
    }
  },
  created () {
    this.getHeadersCol()
    this.getList()
    this.isRowSelectable = params => {
      return params.data.examStatus !== '1'
    }
  },
  methods: {
    // 查看考试中的详情
    getExamDetail (params) {
      console.log(params)
      this.addOrUpdateForm = JSON.parse(JSON.stringify(params))
      this.$refs.examDetail.getDetail(this.addOrUpdateForm)
    },
    // 密码查看考试中的详情
    getExamDetailByPwd (params) {
      this.passwordForm.password = ''
      this.examinationIdDialog = params.id
      this.addOrUpdateForm = JSON.parse(JSON.stringify(params))
      this.byPwdFlag = 'getExamDetail'
      this.passwordVisible = true
      setTimeout(() => {
        this.$refs['passwordForm'].resetFields()
      }, 10)
    },
    onSortChangedAggrid (event) {
      const api = event.api
      const visibleRowCount = api.getDisplayedRowCount()
      for (let i = 0; i < visibleRowCount; i++) {
        const rowNode = api.getDisplayedRowAtIndex(i)
        console.log(rowNode)
      }
      let aaa = JSON.parse(JSON.stringify(this.rowData))
      if (this.gridApi.getRenderedNodes().length > 1) {
        this.aggridScrollNum = this.gridApi.getRenderedNodes()[1].rowIndex - 1
      } else {
        this.aggridScrollNum = this.gridApi.getRenderedNodes()[0].rowIndex
      }
      setTimeout(() => {
        this.rowData = JSON.parse(JSON.stringify(aaa))
        setTimeout(() => {
          if (this.aggridScrollNum !== 0) {
            this.gridApi.ensureIndexVisible(this.aggridScrollNum, 'top')
          }
        }, 10)
      }, 10)
    },
    onFilterChangedAggrid (event) {
      const api = event.api
      const visibleRowCount = api.getDisplayedRowCount()
      for (let i = 0; i < visibleRowCount; i++) {
        const rowNode = api.getDisplayedRowAtIndex(i)
        console.log(rowNode)
      }
      let aaa = JSON.parse(JSON.stringify(this.rowData))
      if (this.gridApi.getRenderedNodes().length > 1) {
        this.aggridScrollNum = this.gridApi.getRenderedNodes()[1].rowIndex - 1
      } else {
        this.aggridScrollNum = this.gridApi.getRenderedNodes()[0].rowIndex
      }
      setTimeout(() => {
        this.rowData = JSON.parse(JSON.stringify(aaa))
        setTimeout(() => {
          if (this.aggridScrollNum !== 0) {
            this.gridApi.ensureIndexVisible(this.aggridScrollNum, 'top')
          }
        }, 10)
      }, 10)
    },
    changeTurn (val) {
      let msg = ''
      let color = ''
      if (val.ifUse === '1') {
        msg = '请确认是否关闭？'
        color = '#ff0000b5'
      } else {
        msg = '请确认是否启用？'
        color = '#00b99e'
      }
      console.log(val)
      let params = {
        id: val.id,
        ifUse: val.ifUse === '1' ? '0' : '1'
      }
      const h = this.$createElement
      this.$msgbox({
        title: '提示',
        message: h('p', { class: 'flex', style: 'justify-content:flex-start;width: 400px' }, [
          h(
            'i',
            {
              class: 'icon iconfont icon-tongzhi',
              style: `color: ${color};font-size: 26px !important;padding-right: 10px`
            },
            ''
          ),
          h('span', null, `${msg}`)
        ]),
        showCancelButton: true,
        closeOnClickModal: false,
        closeOnPressEscape: false,
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        beforeClose: (action, instance, done) => {
          if (action === 'confirm') {
            instance.confirmButtonLoading = true
            instance.confirmButtonText = '操作中...'
            recordsxishuSaveB(params)
              .then(res => {
                done()
                instance.confirmButtonLoading = false
                if (res.data.code === 0) {
                  this.$message.success('操作成功')
                  this.getList()
                }
              })
              .catch(() => {
                instance.confirmButtonLoading = false
                done()
              })
          } else {
            done()
          }
        }
      })
    },
    // 导出Excel
    getExcelHandle (val) {
      let params = {
        recordsId: val.id
      }
      checkStudent(params).then(res => {
        // data : 1,可以下载  0:不可以下载
        if (res.data.data === 1) {
          // this.$message.success('可以下载')
          this.exportHandle(val)
        } else {
          this.$message.success('请先完善考生')
        }
      })
    },
    // 导出excel
    exportHandle (val) {
      console.log('val', val.recordsName)
      this.$http({
        url: '/excel/student/recordsOrder',
        method: 'post',
        responseType: 'blob',
        params: { recordsId: val.id }
      }).then(({ data }) => {
        var binaryData = []
        binaryData.push(data)
        let blob = new Blob(binaryData, {
          type: ' application/vnd.ms-excel '
        })
        setTimeout(() => {
          if (window.navigator.msSaveOrOpenBlob) {
            navigator.msSaveBlob(blob, 'link')
          } else {
            const link = document.createElement('a')
            console.log(window.URL.createObjectURL)

            link.download = val.recordsName
            link.style.display = 'none'
            link.href = window.URL.createObjectURL(blob)
            document.body.appendChild(link)
            link.click()
            URL.revokeObjectURL(link.href)
            document.body.removeChild(link)
            this.$message.success(`${val.recordsName}导出成功`)
          }
        })
      }).catch(err => {
        console.log(err)
      })
    },
    getZipHandle (val) {
      let params = {
        studentPoolId: val.studentPoolId,
        recordsId: val.id
      }
      this.$http({
        url: '/excel/student/getZip',
        method: 'post',
        responseType: 'blob',
        params: params
      }).then(({ data }) => {
        var binaryData = []
        binaryData.push(data)
        let blob = new Blob(binaryData, {
          // type: ' application/vnd.ms-excel '
          type: ' application/zip '
        })
        console.log(blob)
        setTimeout(() => {
          if (window.navigator.msSaveOrOpenBlob) {
            navigator.msSaveBlob(blob, 'link')
          } else {
            const link = document.createElement('a')
            console.log(window.URL.createObjectURL)
            link.download = val.recordsName
            link.style.display = 'none'
            link.href = window.URL.createObjectURL(blob)
            document.body.appendChild(link)
            link.click()
            URL.revokeObjectURL(link.href)
            document.body.removeChild(link)
            this.$message.success(`${val.recordsName}导出成功`)
          }
        })
      }).catch(err => {
        console.log(err)
      })
    },
    // 获取选中
    getSelectedRows () {
      this.dataSelect = this.gridApi.getSelectedRows()
    },
    // 删除
    delHandle (val) {
      if (val === 'branch') {
        let arr = this.dataSelect.filter(v => {
          return v.examStatus === '1'
        })
        if (arr.length >= 1) {
          this.$message.warning('选中数据包含已经结束的考试')
          return
        }
      }
      let msg = val === 'branch' ? '选中数据' : val.recordsName
      let params = val === 'branch' ? this.dataSelect.map(item => {
        return item.id
      }) : [val.id]
      console.log(params)
      const h = this.$createElement
      this.$msgbox({
        title: '提示',
        message: h('p', { class: 'flex', style: 'justify-content:flex-start;width: 400px' }, [
          h(
            'i',
            {
              class: 'el-icon-delete-solid',
              style: 'color: #ff0000b5;font-size: 26px;padding-right: 10px'
            },
            ''
          ),
          h('span', null, `此操作将删除“${msg}”`)
        ]),
        showCancelButton: true,
        closeOnClickModal: false,
        closeOnPressEscape: false,
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        beforeClose: (action, instance, done) => {
          if (action === 'confirm') {
            instance.confirmButtonLoading = true
            instance.confirmButtonText = '删除中...'
            recordsDelete(params)
              .then(res => {
                done()
                instance.confirmButtonLoading = false
                if (res.data.code === 0) {
                  this.$message.success('删除成功')
                  this.getList()
                }
              })
              .catch(() => {
                instance.confirmButtonLoading = false
                done()
              })
          } else {
            done()
          }
        }
      })
    },
    // 关闭
    closeHandle (val) {
      if (val !== 'noFresh') {
        this.examTestVisible = false
        this.getList()
      } else {
        this.getList()
        this.examTestVisible = false
      }
    },

    // 获取表头
    getHeadersCol () {
      this.columnDefs = []
      setTimeout(() => {
        this.col = JSON.parse(JSON.stringify(listJson.column))
        this.columnDefs = this.rowIndexArr.concat(this.col)
      }, 10)
    },
    // 装载列表
    onGridReady (params) {
      this.gridApi = params.api
    },
    // 导出二维码 B类
    getQRHandle (val) {
      console.log(val)
      let params = {
        text: `${window.SITE_CONFIG.baseWebUrl}/osceH5/#/pages/searchOrder?recordsId=${val.id}`
      }
      getQrCode(params).then(res => {
        let qrBase64 = res.data.data
         // 这里是获取到的图片base64编码,这里只是个例子哈，要自行编码图片替换这里才能测试看到效果
        const imgUrl = `data:image/png;base64,${qrBase64}`
        // 如果浏览器支持msSaveOrOpenBlob方法（也就是使用IE浏览器的时候），那么调用该方法去下载图片
        if (window.navigator.msSaveOrOpenBlob) {
          const bstr = atob(imgUrl.split(',')[1])
          let n = bstr.length
          const u8arr = new Uint8Array(n)
          while (n--) {
            u8arr[n] = bstr.charCodeAt(n)
          }
          const blob = new Blob([u8arr])
          window.navigator.msSaveOrOpenBlob(blob, 'chart-download' + '.' + 'png')
        } else {
          // 这里就按照chrome等新版浏览器来处理
          const a = document.createElement('a')
          a.href = imgUrl
          a.setAttribute('download', `${val.recordsName}--二维码`)
          a.click()
        }
      })
    },
    // 导出二维码 A类
    getQRHandleA (val) {
      console.log(val)
      let params = {
        text: `${window.SITE_CONFIG.baseWebUrl}/osceH5/#/pages/anonymous?recordsId=${val.id}`
      }
      getQrCode(params).then(res => {
        let qrBase64 = res.data.data
         // 这里是获取到的图片base64编码,这里只是个例子哈，要自行编码图片替换这里才能测试看到效果
        const imgUrl = `data:image/png;base64,${qrBase64}`
        // 如果浏览器支持msSaveOrOpenBlob方法（也就是使用IE浏览器的时候），那么调用该方法去下载图片
        if (window.navigator.msSaveOrOpenBlob) {
          const bstr = atob(imgUrl.split(',')[1])
          let n = bstr.length
          const u8arr = new Uint8Array(n)
          while (n--) {
            u8arr[n] = bstr.charCodeAt(n)
          }
          const blob = new Blob([u8arr])
          window.navigator.msSaveOrOpenBlob(blob, 'chart-download' + '.' + 'png')
        } else {
          // 这里就按照chrome等新版浏览器来处理
          const a = document.createElement('a')
          a.href = imgUrl
          a.setAttribute('download', `${val.recordsName}--匿名抽号二维码`)
          a.click()
        }
      })
    },
    getList () {
      let params = {
        limit: this.page.pageSize,
        page: this.page.currentPage,
        orderSql: 'creat_date desc',
        recordsName: this.searchForm.recordsName || ''
      }
      fetchList(params).then(res => {
        this.rowData = res.data.page.records
        this.rowData.map(v => {
          v.examStatusName = String(v.examStatus) === '0' ? '待考试' : String(v.examStatus) === '1' ? '已结束' : '暂无'
        })
        this.page.total = res.data.page.total
        this.dataSelect = []
      })
    },
    handleSizeChange (val) {
      this.page.pageSize = val
      this.getList()
    },
    handleCurrentChange (val) {
      this.page.currentPage = val
      this.getList()
    },
    // 清空搜索
    searchReset () {
      this.searchForm = {}
      this.page.currentPage = 1
      // this.getList();
    },

    handleClosePwd () {
      this.passwordVisible = false
    },

    // 校验密码
    submitPassword (form) {
      this.$refs[form].validate((valid) => {
        if (valid) {
          let params = {
            id: this.examinationIdDialog,
            type: 2,
            passwordType: '1',
            password: this.passwordForm.password
          }
          this.passwordCheck = this.passwordForm.password
          console.log('this.passwordCheck', this.passwordCheck)
          authCheck(params).then(res => {
            if (res.data.code === 0) {
              this.$message.success(res.data.msg || '密码正确')
              if (this.byPwdFlag === 'edit' || this.byPwdFlag === 'view') {
                setTimeout(() => {
                  this.$refs['passwordForm'].resetFields()
                  this.passwordVisible = false
                  this.addOrUpdateVisible = true
                  if (params.passwordType === '1') {
                    this.addOrUpdateForm.passwordType = true
                    this.addOrUpdateForm.password = this.passwordCheck
                    this.addOrUpdateForm.checkPassword = this.passwordCheck
                  } else {
                    this.addOrUpdateForm.passwordType = false
                  }
                  let aaa = JSON.parse(JSON.stringify(this.addOrUpdateForm))
                  this.addOrUpdateForm = {}
                  this.addOrUpdateForm = JSON.parse(JSON.stringify(aaa))
                  this.$refs['passwordForm'].resetFields()
                  this.passwordVisible = false
                  // 判断是编辑还是查看
                  if (this.byPwdFlag === 'view') {
                    this.viewHandle(this.addOrUpdateForm, true)
                  } else {
                    this.editHandle(this.addOrUpdateForm, true)
                  }
                }, 1000)
              } else if (this.byPwdFlag === 'del') {
                this.$refs['passwordForm'].resetFields()
                this.passwordVisible = false
                this.delHandle(this.addOrUpdateForm)
              } else if (this.byPwdFlag === 'import') {
                this.$refs['passwordForm'].resetFields()
                this.passwordVisible = false
                this.importHandle(this.addOrUpdateForm)
              } else if (this.byPwdFlag === 'getZip') {
                this.$refs['passwordForm'].resetFields()
                this.passwordVisible = false
                this.getZipHandle(this.addOrUpdateForm)
              } else if (this.byPwdFlag === 'getExcel') {
                this.$refs['passwordForm'].resetFields()
                this.passwordVisible = false
                this.getExcelHandle(this.addOrUpdateForm)
              } else if (this.byPwdFlag === 'getExamDetail') {
                this.$refs['passwordForm'].resetFields()
                this.passwordVisible = false
                this.$refs.examDetail.getDetail(this.addOrUpdateForm)
              }
            }
          })
        } else {
          return false
        }
      })
    },
    // 重制密码
    resetItem (val) {
      const h = this.$createElement
      this.$msgbox({
        title: '重置密码',
        message: h('p', null, [
          h('i', { class: 'icon iconfont icon-zhongzhimima', style: 'color: red;font-weight: 600;font-size: 20px !important;padding-right: 10px' }, ''),
          h('span', null, '此操作将重置密码！请确认是否继续')
        ]),
        showCancelButton: true,
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        beforeClose: (action, instance, done) => {
          if (action === 'confirm') {
            instance.confirmButtonLoading = true
            instance.confirmButtonText = '操作中...'
            initializePwd({type: 2, id: val.id}).then(res => {
              if (res.data.code === 0) {
                this.$message.success('密码重置成功')
                done()
                setTimeout(() => {
                  instance.confirmButtonLoading = false
                }, 300)
              }
            })
          } else {
            done()
          }
        }
      })
    },
    // 通过密码查看
    passwordByView (params) {
      this.passwordForm.password = ''
      this.examinationIdDialog = params.id
      this.addOrUpdateForm = JSON.parse(JSON.stringify(params))
      this.addOrUpdateFlag = 'view'
      this.byPwdFlag = 'view'
      this.passwordVisible = true
      setTimeout(() => {
        this.$refs['passwordForm'].resetFields()
      }, 10)
    },
    // 通过密码编辑
    passwordByEdit (params) {
      this.passwordForm.password = ''
      this.examinationIdDialog = params.id
      this.addOrUpdateForm = JSON.parse(JSON.stringify(params))
      this.addOrUpdateFlag = 'edit'
      this.byPwdFlag = 'edit'
      this.passwordVisible = true
      setTimeout(() => {
        this.$refs['passwordForm'].resetFields()
      }, 10)
    },
    // 通过密码导出 压缩包
    getZipByPwdHandle (params) {
      this.passwordForm.password = ''
      this.examinationIdDialog = params.id
      this.addOrUpdateForm = JSON.parse(JSON.stringify(params))
      this.passwordVisible = true
      this.byPwdFlag = 'getZip'
      setTimeout(() => {
        this.$refs['passwordForm'].resetFields()
      }, 10)
    },
    // 通过密码导出 excel
    getExcelByPwdHandle (params) {
      this.passwordForm.password = ''
      this.examinationIdDialog = params.id
      this.addOrUpdateForm = JSON.parse(JSON.stringify(params))
      this.passwordVisible = true
      this.byPwdFlag = 'getExcel'
      setTimeout(() => {
        this.$refs['passwordForm'].resetFields()
      }, 10)
    },
    // 通过密码 删除
    delByPwdHandle (params) {
      this.passwordForm.password = ''
      this.examinationIdDialog = params.id
      this.addOrUpdateForm = JSON.parse(JSON.stringify(params))
      this.passwordVisible = true
      this.byPwdFlag = 'del'
      setTimeout(() => {
        this.$refs['passwordForm'].resetFields()
      }, 10)
    },
    // 新增考试
    addExamTest () {
      this.examTestVisible = true
      this.addOrEdit = 'add'
      this.$refs.examTextAddEdit.resetData()
      this.$refs.examTextAddEdit.getExamStation()
      // this.$refs.examTextAddEdit.getTeacher()
      // this.$refs.examTextAddEdit.getExamList()
      this.$refs.examTextAddEdit.getTestLibrary()
    },
    // 只是查看
    viewHandle (val, usePwd) {
      if (!usePwd) {
        this.passwordCheck = ''
      }
      setTimeout(() => {
        if (val.type === 'B类') {
          this.examTestVisible = true
          this.addOrEdit = 'view'
          this.$refs.examTextAddEdit.getRecordsDetail(val.id)
          this.$refs.examTextAddEdit.getExamStation()
          // this.$refs.examTextAddEdit.getTeacher()
          // this.$refs.examTextAddEdit.getExamList()
          this.$refs.examTextAddEdit.getTestLibrary()
        } else {
          this.examTestCountryVisible = true
          this.addOrEditCountry = 'view'
          this.$refs.addEditExamCountry.getRecordsDetail(val.id)
          this.$refs.addEditExamCountry.getExamStation()
          // this.$refs.addEditExamCountry.getTeacher()
          // this.$refs.addEditExamCountry.getExamList()
          this.$refs.addEditExamCountry.getTestLibrary()
        }
      }, 10)
    },
    // handel
    editHandle (val, usePwd) {
      if (!usePwd) {
        this.passwordCheck = ''
      }
      setTimeout(() => {
        if (val.type === 'B类') {
          this.examTestVisible = true
          this.addOrEdit = 'edit'
          this.$refs.examTextAddEdit.getRecordsDetail(val.id)
          this.$refs.examTextAddEdit.getExamStation()
          // this.$refs.examTextAddEdit.getTeacher()
          // this.$refs.examTextAddEdit.getExamList()
          this.$refs.examTextAddEdit.getTestLibrary()
        } else {
          this.examTestCountryVisible = true
          this.addOrEditCountry = 'edit'
          this.$refs.addEditExamCountry.getRecordsDetail(val.id)
          this.$refs.addEditExamCountry.getExamStation()
          // this.$refs.addEditExamCountry.getTeacher()
          // this.$refs.addEditExamCountry.getExamList()
          this.$refs.addEditExamCountry.getTestLibrary()
        }
      }, 10)
    },
    // 新增A类考试
    addExamTestCountry () {
      this.examTestCountryVisible = true
      this.addOrEditCountry = 'add'
      this.$refs.addEditExamCountry.resetData()
      this.$refs.addEditExamCountry.getExamStation()
      // this.$refs.addEditExamCountry.getTeacher()
      // this.$refs.addEditExamCountry.getExamList()
      this.$refs.addEditExamCountry.getTestLibrary()
    },
    // 关闭新增考试
    closeHandleCountry (val) {
      if (val !== 'noFresh') {
        this.examTestCountryVisible = false
        this.getList()
      } else {
        this.getList()
        this.examTestCountryVisible = false
      }
    }
  }
}
</script>
<style lang='scss'>
.el-tooltip__popper.is-light{
  background: #d3ede9;
  border: 1px solid #00b99e;
}
.tipCon{
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 300px;
  .title{
    font-size: 16px;
    font-weight: 600;
    color: #00b99e;
    padding-bottom: 8px;
  }
  .line{
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    font-size: 14px;
    font-weight: 500;
    width: 100%;
    .order{
      color: #00b99e;
      width: 24px;
    } 
    .orderCon{
      flex: 1;
    }
  }
}
</style>